//
// Decompiled by Jadx - 404ms
//
package aa;

import java.io.IOException;
import java.util.List;
import kotlin.jvm.internal.i;
import okhttp3.ae;
import okhttp3.internal.connection.c;
import okhttp3.internal.connection.e;
import okhttp3.u;
import okhttp3.z;

public final class f {
    public int a;
    public final e b;
    public final List<u> c;
    public final int d;
    public final c e;
    public final z f;
    public final int g;
    public final int h;
    public final int i;

    public f(e eVar, List<? extends u> list, int i, c cVar, z zVar, int i2, int i3, int i4) {
        i.f(eVar, "call");
        i.f(list, "interceptors");
        i.f(zVar, "request");
        this.b = eVar;
        this.c = list;
        this.d = i;
        this.e = cVar;
        this.f = zVar;
        this.g = i2;
        this.h = i3;
        this.i = i4;
    }

    public static f j(f fVar, int i, c cVar, z zVar, int i2) {
        int i3;
        int i4;
        int i5;
        if ((i2 & 1) != 0) {
            i = fVar.d;
        }
        int i6 = i;
        if ((i2 & 2) != 0) {
            cVar = fVar.e;
        }
        c cVar2 = cVar;
        if ((i2 & 4) != 0) {
            zVar = fVar.f;
        }
        z zVar2 = zVar;
        if ((i2 & 8) != 0) {
            i3 = fVar.g;
        } else {
            i3 = 0;
        }
        if ((i2 & 16) != 0) {
            i4 = fVar.h;
        } else {
            i4 = 0;
        }
        if ((i2 & 32) != 0) {
            i5 = fVar.i;
        } else {
            i5 = 0;
        }
        fVar.getClass();
        i.f(zVar2, "request");
        return new f(fVar.b, fVar.c, i6, cVar2, zVar2, i3, i4, i5);
    }

    public final ae k(z zVar) throws IOException {
        boolean z;
        boolean z2;
        boolean z3;
        i.f(zVar, "request");
        List<u> list = this.c;
        int size = list.size();
        boolean z4 = false;
        int i = this.d;
        if (i < size) {
            z = true;
        } else {
            z = false;
        }
        if (z) {
            this.a++;
            c cVar = this.e;
            if (cVar != null) {
                if (cVar.e.l(zVar.b)) {
                    if (this.a == 1) {
                        z3 = true;
                    } else {
                        z3 = false;
                    }
                    if (!z3) {
                        throw new IllegalStateException(("network interceptor " + list.get(i - 1) + " must call proceed() exactly once").toString());
                    }
                } else {
                    throw new IllegalStateException(("network interceptor " + list.get(i - 1) + " must retain the same host and port").toString());
                }
            }
            int i2 = i + 1;
            f j = j(this, i2, null, zVar, 58);
            u uVar = list.get(i);
            ae c = uVar.c(j);
            if (c != null) {
                if (cVar != null) {
                    if (i2 < list.size() && j.a != 1) {
                        z2 = false;
                    } else {
                        z2 = true;
                    }
                    if (!z2) {
                        throw new IllegalStateException(("network interceptor " + uVar + " must call proceed() exactly once").toString());
                    }
                }
                if (c.h != null) {
                    z4 = true;
                }
                if (z4) {
                    return c;
                }
                throw new IllegalStateException(("interceptor " + uVar + " returned a response with no body").toString());
            }
            throw new NullPointerException("interceptor " + uVar + " returned null");
        }
        throw new IllegalStateException("Check failed.".toString());
    }
}
